package p2p.model.vo
{
	public class MessageVO
	{
		public var id:String;
		public var recipientMessage:String;
		public var ownerMessage:String;
		public var recipientSessionKey:String;
		public var ownerSessionKey:String;
		public var nameNotification:Boolean;
		public var type:uint;
		
		public var data:Object;
		
		public static const TEXT_MSG_TYPE:uint = 0;
		public static const FILE_TYPE:uint = 1;
		
		public function MessageVO(recipientMessage:String, 
								  ownerMessage:String,
								  recipientSessionKey:String,
								  ownerSessionKey:String, 
								  id:String = null,
								  type:uint = TEXT_MSG_TYPE,
								  data:Object = null) : void
		{
			if (!id)
				this.id = Math.ceil(Math.random() * 1000000) + ownerSessionKey;
			this.recipientMessage = recipientMessage;
			this.ownerMessage = ownerMessage;
			this.recipientSessionKey = recipientSessionKey;
			this.ownerSessionKey = ownerSessionKey;
			this.type = type;
			this.data = data;
		}
		
		public static function getMessageFromObject(obj:Object) : MessageVO
		{
			var clone:MessageVO = new MessageVO(obj.recipientMessage, obj.ownerMessage, obj.recipientSessionKey, obj.ownerSessionKey, obj.id, obj.type, obj.data);
			clone.nameNotification = obj.nameNotification;
			return clone;
		}
	}
}